package com.baseframe.tool.utils.web;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class WebUtil {
    public static HttpServletRequest getRequest() {
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        if (requestAttributes==null){
            throw new RuntimeException("获取当前请求失败~");
        }
        return ((ServletRequestAttributes) requestAttributes).getRequest();
    }
}
